#include <avr/io.h>             // this contains all the IO port definitions
#include <avr/pgmspace.h>       // definitions or keeping constants in program memory
#include "main.h"

// table of POWER codes

#define freq_to_timerval(x) ((F_CPU / x - 1 )/ 2)

  
// Code 000 -- Sony, Baur, Neckermann, Otto Versand, Palladium, Quelle, SEI, Sinudyne, Sonolor, Universum
const struct powercode sonyCode PROGMEM = {
  freq_to_timerval(37470), // 37.47 KHz  
  {{245, 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {61 , 60},
   {61 , 2759},
   {245, 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {61 , 60},
   {61 , 0}// end of code
  }
};

//Code 001 - Proscan, RCA, Curtis Mathes, Dimensia, GE, JC Penney, LXI, Radio Shack/Realistic, Sears, Wards
const struct powercode rcaCode PROGMEM = {
  freq_to_timerval(55600), // 55.6 KHz  
  {{ 411,   410 },
   {  52,   205 },
   {  52,   205 },
   {  52,   205 },
   {  52,   205 },
   {  52,   102 },
   {  52,   102 },
   {  52,   205 },
   {  52,   102 },
   {  52,   205 },
   {  52,   102 },
   {  52,   205 },
   {  52,   102 },
   {  52,   102 },
   {  52,   102 },
   {  52,   102 },
   {  52,   102 },
   {  52,   205 },
   {  52,   205 },
   {  52,   102 },
   {  52,   205 },
   {  52,   102 },
   {  52,   205 },
   {  52,   102 },
   {  52,   205 },
   {  52,   821 },
   { 411,   410},
   {  52,   205},
   {  52,   205},
   {  52,   205},
   {  52,   205},
   {  52,   102},
   {  52,   102},
   {  52,   205},
   {  52,   102},
   {  52,   205},
   {  52,   102},
   {  52,   205},
   {  52,   102},
   {  52,   102},
   {  52,   102},
   {  52,   102},
   {  52,   102},
   {  52,   205},
   {  52,   205},
   {  52,   102},
   {  52,   205},
   {  52,   102},
   {  52,   205},
   {  52,   102},
   {  52,   205},
   {  52,   0}
  }
};

// Code 002 -- Panasonic
const struct powercode panasonicCode PROGMEM = {
  freq_to_timerval(36130), // 36.13 KHz
  {{ 358,   179 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,  7720 },
   { 358,   180 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,    45 },
   {  44,    45 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,   135 },
   {  44,    45 },
   {  44,   135 },
   {  44,     0 }}
};

// Code 003 -- Sharp
const struct powercode sharpCode PROGMEM = {
  freq_to_timerval( 37470), // 37.47 KHz
  {{  28,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,  4670 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,   189 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,  4670 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,  4670 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,    81 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,   189 },
   {  29,   189 },
   {  29,    81 },
   {  29,   189 },
   {  29,     0 }}
};

// Code 004 -- Toshiba, Apex
const struct powercode toshibaCode PROGMEM = {
  freq_to_timerval( 37470), // 37.47 KHz
  {{ 924,   464 },
   {  58,    57 },
   {  58,    57 },
   {  58,    57 },
   {  58,    57 },
   {  58,    57 },
   {  58,    57 },
   {  58,   173 },
   {  58,    57 },
   {  58,   173 },
   {  58,   173 },
   {  58,   173 },
   {  58,   173 },
   {  58,   173 },
   {  58,   173 },
   {  58,    57 },
   {  58,   173 },
   {  58,    57 },
   {  58,   173 },
   {  58,    57 },
   {  58,    57 },
   {  58,   173 },
   {  58,    57 },
   {  58,    57 },
   {  58,    57 },
   {  58,   173 },
   {  58,    57 },
   {  58,   173 },
   {  58,   173 },
   {  58,    57 },
   {  58,   173 },
   {  58,   173 },
   {  58,   173 },
   {  58,  4054 },
   { 926,   230 },
   {  58,  9880 },
   { 926,   230 },
   {  58,     0 },						       
  }
};

// Code 005 -- Philips, Grundig, Pye
const struct powercode philipsCode PROGMEM = {
  freq_to_timerval( 34800), // 37.47 KHz
  {  {  92,    92 },
     { 184,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,   184 },
     {  92,    92 },
     { 184,    92 },
     {  92,  9216 },
     {  92,    92 },
     { 184,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,    92 },
     {  92,   184 },
     {  92,    92 },
     { 184,    92 },
     {  92,     0 },
  }
};

// Code 006 -- Samsung
const struct powercode samsungCode PROGMEM = {
  freq_to_timerval( 37470), // 37.47 KHz
  {{ 462,   476 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,    62 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,  4661 },
   { 464,   476 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,    62 },
   {  53,   175 },
   {  53,    62 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,   175 },
   {  53,     0 },
  }
};

// Code 007 -- Zenith
const struct powercode zenithCode PROGMEM = {
  freq_to_timerval( 38200), 
  {{  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,   522 },
   {  52,    49 },
   {  52, 12433 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,    49 },
   {  52,   419 },
   {  52,   522 },
   {  52,   522 },
   {  52,    49 },
   {  52,     0 },
  }
};

// Code 008 --Pioneer, Sansui, Toshiba
const struct powercode pioneerCode PROGMEM = {
  freq_to_timerval( 37470), 
  {{924,  462},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59, 4117},
   {926,  459},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,  173},
   { 59,   59},
   { 59,  173},
   { 59,    0}}
};

// Code 009 -- Sylvania
const struct powercode sylvaniaCode PROGMEM = {
  freq_to_timerval( 37430), 
  {{924, 461},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 174},
   {56, 56},
   {56, 174},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 174},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 174},
   {56, 56},
   {56, 56},
   {56, 56},
   {56, 4055},
   {926, 230},
   {56, 9855},
   {926, 230},
   {56, 0}
  }
};

// Code 010 -- JVC
const struct powercode jvcCode PROGMEM = {
  freq_to_timerval( 37470), 
  { {865,	429},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	161},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	2347},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	161},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	2347},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	161},
    {53,	161},
    {53,	161},
    {53,	55},
    {53,	161},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	0}}
};

// Code 011 -- Hitachi
const struct powercode hitachiCode PROGMEM = {
  freq_to_timerval( 37470), 
  { {909,	452},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	175},
    {58,	175},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	175},
    {58,	175},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	55},
    {58,	175},
    {58,	55},
    {58,	175},
    {58,	175},
    {58,	175},
    {58,	4146},
    {910,	229},
    {58,	9597},
    {910,	229},
    {56,	0} }
};

// Code 012 -- Sampo
const struct powercode sampoCode PROGMEM = {
  freq_to_timerval( 37470), 
  { {342,	343},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	260},
    {85,	3366},
    {342,	344},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	87},
    {85,	87},
    {85,	260},
    {85,	260},
    {85,	260},
    {85,	0}}
};

// Code 013 -- Hisense
const struct powercode hisenseCode PROGMEM = {
  freq_to_timerval( 37520), 
  { {918,	459},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	170},
    {56,	55},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	55},
    {56,	55},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	55},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	170},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	170},
    {56,	170},
    {56,	55},
    {56,	170},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	55},
    {56,	55},
    {56,	55},
    {56,	170},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	55},
    {56,	170},
    {56,	170},
    {56,	170},
    {56,	2364},
    {920,	458},
    {56,	9620},
    {920,	458},
    {56,	0}}
};

// Code 014 -- Viewsonic, Acer
const struct powercode viewsonicCode PROGMEM = {
  freq_to_timerval( 37470), 
  { {924,	464},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	4054},
    {926,	230},
    {58,	9880},
    {926,	230},
    {58,	0}}
};

// Code 015 -- Bush, NET-TV
const struct powercode bushCode PROGMEM = {
  freq_to_timerval( 37470), 
  { {924,	464},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	4054},
    {926,	230},
    {58,	9880},
    {926,	230},
    {58,	0}}
};

// Code 016 -- AOC, Daewoo, Goldstar, JC Penney, LG, Memorex, MGA, 
// Mistubishi, MTC, NEC, Philco, Portland, RCA, Samsung, 
// Teknika, Vidtech, Wards, Yamaha
const struct powercode aocCode PROGMEM = {
  freq_to_timerval(33600), 
  { {30,	215},
    {30,	216},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	2573},
    {30,	216},
    {30,	216},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	216},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	91},
    {30,	0}}
};

// Code 017 -- Bell & Howell, Curtis Mathes, Emerson, Fisher, LXI, Memorex, 
// Radio Shack, Realistic, Sanyo, Sears, Toshiba
const struct powercode bellCode PROGMEM = {
  freq_to_timerval(38970), 
  { {924,	459},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	178},
    {59,	4260},
    {924,	231},
    {59,	9753},
    {924,	231},
    {59,	0}}
};

// Code 018 -- Pioneer, Hitachi
const struct powercode pioneer2Code PROGMEM = {
  freq_to_timerval(37470),
  { {873,	439},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	164},
    {53,	2633},
    {873,	440},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	164},
    {53,	2633},
    {873,	440},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	164},
    {53,	55},
    {53,	55},
    {53,	55},
    {53,	164},
    {53,	0}}
};

// Code 019 -- Fujitsu
const struct powercode fujitsuCode PROGMEM = {
  freq_to_timerval(37470),
  { {335,	166},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	4723},
    {336,	166},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	126},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	42},
    {43,	0}}
};


// Code 020 - Gold Star, JC Penney, LXI, Marantz, Memorex, Proton, Pulsar, 
// Toshiba, Wards

const struct powercode goldstarCode PROGMEM = {
  freq_to_timerval(37470),
  { {924,	472},
    {63,	55},
    {63,	55},
    {63,	166},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	166},
    {63,	166},
    {63,	55},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	166},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	55},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	55},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	166},
    {63,	4207},
    {926,	234},
    {63,	9957},
    {926,	234},
    {62,	0}}
};


// Code 021 - Daewoo, Emerson, Hitachi, RCA, White Westinghouse, Zenith
const struct powercode daewooCode PROGMEM = {
  freq_to_timerval(37470),
  { {821,	409},
    {51,	52},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	52},
    {51,	52},
    {51,	409},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	52},
    {51,	52},
    {51,	2397},
    {822,	409},
    {51,	52},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	52},
    {51,	52},
    {51,	409},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	163},
    {51,	52},
    {51,	52},
    {51,	52},
    {51,	0}}
};


// Code 022 - NEC
const struct powercode NECCode PROGMEM = {
  freq_to_timerval(37470),
  {
    {918,	460},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	179},
    {56,	179},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	179},
    {56,	179},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	61},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	179},
    {56,	61},
    {56,	61},
    {56,	4581},
    {921,	230},
    {56,	9705},
    {921,	230},
    {56,	0}
  }
};

// Code 023 - Admiral, Bell & Howell, Logik, Majestic, Memorex, 
// Montgomery Ward, Signature, Teknika, Wards, Zenith
const struct powercode admiralCode PROGMEM = {
  freq_to_timerval(39010),
  {
    {51,	516},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	10746},
    {51,	516},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	52},
    {51,	418},
    {51,	516},
    {51,	52},
    {51,	418},
    {51,	0}  }
};
// Code 024 - Sony
const struct powercode sony2Code PROGMEM = {
  freq_to_timerval(37470),
  { {245,	60},
    {123,	60},
    {123,	60},
    {123,	60},
    {123,	60},
    {61,	60},
    {123,	60},
    {61,	60},
    {123,	60},
    {61,	60},
    {61,	60},
    {61,	60},
    {61,	2636},
    {246,	60},
    {123,	60},
    {123,	60},
    {123,	60},
    {123,	60},
    {61,	60},
    {123,	60},
    {61,	60},
    {123,	60},
    {61,	60},
    {61,	60},
    {61,	60},
    {61,	0}  }
};

// Code 025 - Viewsonic, Magnavox, NET-TV, Electrograph, Gateway, Maxent, 
// NetTV, Sampo

const struct powercode viewsonic2Code PROGMEM = {
  freq_to_timerval(37470),
  {  {357,	358},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	3562},
    {358,	358},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	91},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	270},
    {88,	0},
  }
};


// Code 026 - Zenith
const struct powercode zenith2Code PROGMEM = {
  freq_to_timerval(38200),
  { {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	12922},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	419},
    {52,	522},
    {52,	49},
    {52,	0}}
};


// Code 027 - Thompson
const struct powercode thompsonCode PROGMEM = {
  freq_to_timerval(55600),
  { {411,	410},
    {52,	102},
    {52,	205},
    {52,	205},
    {52,	205},
    {52,	102},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	102},
    {52,	102},
    {52,	205},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	821},
    {411,	410},
    {52,	102},
    {52,	205},
    {52,	205},
    {52,	205},
    {52,	102},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	102},
    {52,	102},
    {52,	205},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {52,	102},
    {52,	205},
    {51,	0}}
};

// Code 028  - Brillian, Sears
const struct powercode brillianCode PROGMEM = {
  freq_to_timerval(37430),
  { {267,	276},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	277},
    {123,	123},
    {123,	123},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	4876},
    {267,	277},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	277},
    {123,	123},
    {123,	123},
    {123,	123},
    {123,	277},
    {123,	123},
    {123,	277},
    {123,	0}}
};
// Code 029 - Magnavox
const struct powercode magnavoxCode PROGMEM = {
  freq_to_timerval(34800),
  { {92,	92},
    {184,	92},
    {92,	92},
    {92,	92},
    {92,	92},
    {92,	92},
    {92,	184},
    {184,	92},
    {92,	184},
    {92,	92},
    {184,	9216},
    {92,	92},
    {184,	92},
    {92,	92},
    {92,	92},
    {92,	92},
    {92,	92},
    {92,	184},
    {184,	92},
    {92,	184},
    {92,	92},
    {184,	0}}
};

// Code 030 - Viewsonic
const struct powercode viewsonic3Code PROGMEM = {
  freq_to_timerval(37470),
  { {924,	461},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	4055},
    {926,	230},
    {56,	9855},
    {926,	230},
    {56,	0}}
};

// Code 031 - Crown, Infinity, JBL, Loewe, LXI, Magnavox, Marantz, 
// Panaxonic, Philco, Philips, Sylvania, Wards
const struct powercode crownCode PROGMEM = {
  freq_to_timerval(34800),
  { {92,	91},
    {92,	91},
    {184,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	182},
    {92,	91},
    {184,	91},
    {92,	9217},
    {92,	91},
    {92,	91},
    {184,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	91},
    {92,	182},
    {92,	91},
    {184,	91},
    {92,	0}}
};

// Code 032 - Hitachi
const struct powercode hitachi2Code PROGMEM = {
  freq_to_timerval(37470),
  { {924,	461},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	56},
    {56,	174},
    {56,	56},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	174},
    {56,	4055},
    {926,	230},
    {56,	9855},
    {926,	230},
    {56,	0} }
};

// Code 033 - Fujitsu
const struct powercode fujitsu2Code PROGMEM = {
  freq_to_timerval(37470),
  { {344,	159},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	5438},
    {347,	157},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	124},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	43},
    {43,	0}}
};


// Code 034 - Hitachi
const struct powercode hitachi3Code PROGMEM = {
  freq_to_timerval(37470),
  { {924,	464},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	4054},
    {925,	230},
    {58,	9880},
    {925,	230},
    {58,	0}}
};


// Code 035 - NEC
const struct powercode NEC2Code PROGMEM = {
  freq_to_timerval(37470),
  { {924,	464},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	57},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	173},
    {58,	4054},
    {926,	230},
    {58,	9880},
    {926,	230},
    {58,	0} }
};


// Code 037 - Anam National, Electrohome, GE, Motorola, NEC, Panasonic, 
// Philco, Philips, Quasar, RCA, Tatung
const struct powercode anamCode PROGMEM = {
  freq_to_timerval(36090),
  { {88,	595},
    {88,	255},
    {88,	255},
    {88,	255},
    {88,	594},
    {88,	255},
    {88,	594},
    {88,	594},
    {88,	594},
    {88,	255},
    {88,	0}}
};


// Code 039 - Candle, Citizen, JC Penney, Magnavox, Philco, Philips, 
// Simpson, Soundesign, Sylvania, Teknika
const struct powercode candleCode PROGMEM = {
  freq_to_timerval(38970),
  { {924,	459},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	57},
    {59,	57},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	57},
    {59,	178},
    {59,	178},
    {59,	178},
    {59,	4262},
    {924,	231},
    {59,	9758},
    {924,	231},
    {59,	0}  
  }
};

// Code 040 - Contec/Cony, Emerson, Goldstar, Hitachi, JVC, Philco,
// Philips, Proton, Radio Shack/Realistic, Samsung, Scott,
// Sharp, Teknika
const struct powercode contecCode PROGMEM = {
  freq_to_timerval(54070),
  { {118,	 103},
    {708,	2778},
    {118,	 103},
    {708,	   0}
  }
};

// Code 041 - Contec/Cony, Hitachi, JC Penney, JVC, Sears, Teknika
const struct powercode contec2Code PROGMEM = {
  freq_to_timerval(38970),
  { {118,	 103},
    {118,	 103},
    {118,	 205},
    {118,	2778},
    {118,	 103},
    {118,	 103},
    {118,	 205},
    {118,	   0}
  }
};

// Code 042 - Sony
const struct powercode sony3Code PROGMEM = {
  freq_to_timerval(74940),
  { {250,	  63},
    {121,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    { 60,	  63},
    { 60,	  63},
    { 60,	2819},
    {250,	  63},
    {121,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    { 60,	  63},
    {121,	  63},
    { 60,	  63},
    { 60,	  63},
    { 60,	  63},
    { 60,	   0}
  }
};





const PGM_P *powerCodes[] PROGMEM  = {
  &sonyCode, &rcaCode, &panasonicCode, &sharpCode, &toshibaCode,
  &philipsCode, &samsungCode,&zenithCode, &pioneerCode, &sylvaniaCode,
  &jvcCode, &hitachiCode, &sampoCode, &hisenseCode, &viewsonicCode,
  &bushCode, &aocCode, &bellCode, &pioneer2Code, &fujitsuCode,
  &goldstarCode, &daewooCode, &NECCode, &admiralCode, &sony2Code,
  &viewsonic2Code, &zenith2Code, &thompsonCode, &brillianCode, &magnavoxCode,
  &viewsonic3Code, &crownCode, &hitachi2Code, &fujitsu2Code, &hitachi3Code,
  &NEC2Code, &anamCode, &candleCode,
  &contecCode, &contec2Code, &sony3Code
};


uint8_t num_codes = (sizeof(powerCodes)/sizeof(*powerCodes));
